1、本地路由信息的添加、删除、获取;
2、订阅连接关闭事件ConnectionCloseEvent,删除本地路由,发布离线事件UserOfflineEvent;
1 | package com.mpush.core.router; |
LocalRouter.java1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52package com.mpush.core.router;
import com.mpush.api.connection.Connection;
import com.mpush.api.router.Router;
/**
* Created by ohun on 2015/12/23.
*
* @author ohun@live.cn
*/
public final class LocalRouter implements Router<Connection> {
private final Connection connection;
public LocalRouter(Connection connection) {
this.connection = connection;
}
public int getClientType() {
return connection.getSessionContext().getClientType();
}
public Connection getRouteValue() {
return connection;
}
public RouterType getRouteType() {
return RouterType.LOCAL;
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LocalRouter that = (LocalRouter) o;
return getClientType() == that.getClientType();
}
public int hashCode() {
return Integer.hashCode(getClientType());
}
public String toString() {
return "LocalRouter{" + connection + '}';
}
}